/**
 * Created by sa on 2016/9/22.
 */

var casper = require('casper').create();

casper.start('https://www.google.com');

casper.thenEvaluate(function(term) {
  console.log("thenEvaluate");
  document.querySelector('input[name="q"]').setAttribute('value', term);
  document.querySelector('form[name="f"]').submit();
}, 'CasperJS');

casper.then(function() {
  // Click on 1st result link
  this.click('h3.r a');
});

casper.then(function() {
  // Click on 1st result link
  this.click('h3.r a',10,10);
});

casper.then(function() {
  // Click on 1st result link
  this.click('h3.r a',"50%","50%");
});


casper.then(function() {
  console.log('clicked ok, new location is ' + this.getCurrentUrl());
});

casper.run();

//casperjs ClickTest.js
